﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.IO;
using System.Text;
using System.ComponentModel;
using System.Windows.Media.Imaging;
using System.Threading;
using System.Security.Cryptography;
using System.Windows.Threading;
using System.Windows;
using BrainTechLLC;
using BrainTechLLC.ThreadSafeObjects;
using AForge;
using AForge.Imaging;
using AForge.Imaging.Filters;
using System.Collections.ObjectModel;
using System.Windows.Media;

namespace WpfImageDuplicates
{
    public class FilterViewModel : INotifyPropertyChanged
    {
        protected SingleFilter _filter;

        public FilterViewModel(SingleFilter filter)
        {
            _filter = filter;
        }

        public string FilterType
        {
            get
            {
                if (_filter == null)
                    return string.Empty;

                return _filter.FilterTypeName;
            }
        }

        public FilterStatus Status
        {
            get
            {
                return _filter.Status;
            }
            set
            {
                if (_filter.Status != value)
                {
                    _filter.Status = value;
                    OnPropertyChanged("Status");
                }
            }
        }

        public bool Disabled
        {
            get
            {
                return (_filter.Status & FilterStatus.Disabled) == FilterStatus.Disabled;
            }
            set
            {
                if (Disabled != value)
                {
                    if (value)
                    {
                        _filter.Status |= FilterStatus.Disabled;
                    }
                    else
                    {
                        _filter.Status &= ~FilterStatus.Disabled;
                    }

                    OnPropertyChanged("Disabled");
                }
            }
        }

        public SingleFilter Filter { get { return _filter; } }

        protected void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }
}
